package br.org.ifrr.controller;

import java.io.Serializable;

import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import br.org.ifrr.model.Inventario;
import br.org.ifrr.service.CadastroInventarioService;
import br.org.ifrr.util.jsf.FacesUtil;

@Named
@ViewScoped
public class CadastroInventarioBean implements Serializable {
	
	private static final long serialVersionUID = 1L;

	@Inject
	private CadastroInventarioService cadastroInventarioService;

	private Inventario inventario;

	public CadastroInventarioBean() {
		limpar();
	}

	private void limpar() {
		inventario = new Inventario();
	}

	public void salvar() {
		this.inventario = cadastroInventarioService.salvar(this.inventario);
		limpar();

		FacesUtil.addInfoMessage("Ano salvo com sucesso.");
	}

	public boolean isEditando() {

		return this.inventario.getId() != null;
	}

	public Inventario getInventario() {
		return inventario;
	}

	public void setInventario(Inventario inventario) {
		this.inventario = inventario;
	}
	
	
}
